<script setup>
import {
    Management,
    Promotion,
    UserFilled,
    User,
    Crop,
    EditPen,
    SwitchButton,
    CaretBottom
} from '@element-plus/icons-vue'
import avatar from '@/assets/default.png'
import { ref } from 'vue'
const classIDStore = useClassIDStore();
import { useClassIDStore } from '@/stores/classID.js'
import {ClassStudentInfoService} from '@/api/teacherApi/classStudentInfo';
const tableData = ref()
const getClassStudentInfo = async () => {
    let result = await ClassStudentInfoService(classIDStore.classID);
    console.log(result)
    tableData.value = result.data;
}
getClassStudentInfo()
import { useRouter } from 'vue-router';
const router = useRouter()
import { useStudentIDStore } from '@/stores/studentID.js'
import { useTeacherIdentityStore } from '@/stores/teacherIdentity.js'
import { useStudentNameStore } from '@/stores/studentName';
const studentIDstore = useStudentIDStore();
const teacherIdentityStore = useTeacherIdentityStore();
const studentNameStore = useStudentNameStore();
const handleClick = async (data) => {
    //console.log(data.studentID)
    studentIDstore.setStudentID(data.studentID)
    teacherIdentityStore.setTeacherIdentity('a')
    studentNameStore.setStudentName(data.name)
    //console.log(data.name)
    router.push('/historyChat');
}
</script>
<template>
    <el-table :data="tableData" style="width: 100%;height: 75vh">
        <el-table-column prop="studentID" label="学号" width="750" />
        <el-table-column prop="name" label="姓名" width="750" />
        <el-table-column fixed="right"  width="120">
            <template #default="props">
                <el-button link type="primary" size="small" @click="handleClick(props.row)">进入</el-button>
            </template>
        </el-table-column>
    </el-table>
</template>
<style lang="scss" scoped></style>